package com.nisco.dms.repository;

import java.util.List;

import javax.persistence.QueryHint;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import com.nisco.dms.entity.Department;

/**
 * 
 * @author joey
 *
 */
public interface DepartmentDao extends JpaRepository<Department, String>{
	Page<Department> findByFatherId(String fatherId, Pageable pageable);
	
	Page<Department> findByFatherIdAndStrNameContaining(String fatherId, String strname, Pageable pageable);
	
	@QueryHints(value={
			@QueryHint(name="org.hibernate.cacheable",value="true"),
			@QueryHint(name="org.hibernate.cacheRegion",value="com.nisco.dms.entity")
		}
	)
	@Query("from Department")
	List<Department> findAllWithCache();
}
